package sbc.corso.shareable;

import sbc.corso.CorsoUtil;
import corso.lang.CorsoConnection;
import corso.lang.CorsoData;
import corso.lang.CorsoDataException;
import corso.lang.CorsoShareable;
import corso.lang.CorsoTopTransaction;
import corso.lang.CorsoVarOid;
import corso.lang.CorsoException;

public class Platine implements CorsoShareable {
	
	private String id;
	private String status;
	private String firstSensor;
	private String secondSensor;
	private String fertigmontiertam;
	private String fertigmontiertvon;

    public Platine (String id, String status) {
        this.id = id;
        this.status = status;
        this.firstSensor = "";
        this.secondSensor = "";
        this.fertigmontiertam="";
        this.fertigmontiertvon = "";
    }
    
    public Platine (String id, String status, String fs, String ss) {
        this.id = id;
        this.status = status;
        this.firstSensor = fs;
        this.secondSensor = ss;
        this.fertigmontiertam="";
        this.fertigmontiertvon = "";
    }

 
    public Platine (CorsoVarOid oid) {
	    //System.out.println ("Read PlatineOid = " + oid);
        try {
            oid.setTimeStamp (0);
            oid.readShareable (this, null, CorsoConnection.NO_TIMEOUT);
        }
        catch (Exception e) {
        	System.out.println("e: " + e);
        	e.printStackTrace();
            System.exit (-9);
        }
    }
 
    public Platine (CorsoVarOid oid, CorsoTopTransaction tx) {
        try {
            oid.setTimeStamp (0);
            oid.readShareable (this, tx, CorsoConnection.NO_TIMEOUT);
        }
        catch (Exception e) {
        	e.printStackTrace();
            System.exit (-9);
        }
    }

	public void read(CorsoData data) throws CorsoDataException {
        StringBuffer structName = new StringBuffer ();
        int arity = data.getStructTag (structName);
        //System.out.println("arity: " + arity);
        if (arity != 6)
            System.exit (-1);
        id = data.getString();
        status = data.getString();   
        //System.out.println("a");
	    firstSensor = data.getString();
	    //System.out.println("b");
	    secondSensor = data.getString(); 
		fertigmontiertam = data.getString();
		fertigmontiertvon = data.getString();
	}

	public void write(CorsoData data) throws CorsoDataException {
		
		//System.out.println("platine1");
		
        data.putStructTag ("Platine", 6);
        data.putString (id);
        data.putString (status);
        //System.out.println("platine1 " + firstSensor);
	    data.putString (firstSensor);
	    //System.out.println("platine2" + secondSensor);
	    data.putString(secondSensor);
	    data.putString(fertigmontiertam);
	    data.putString(fertigmontiertvon);
	    //System.out.println("platine3");
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getFirstSensor() {
		return firstSensor;
	}

	public void setFirstSensor(String firstSensor) {
		this.firstSensor = firstSensor;
	}

	public String getSecondSensor() {
		return secondSensor;
	}

	public void setSecondSensor(String secondSensor) {
		this.secondSensor = secondSensor;
	}
	
	public String getFertigmontiertam() {
		return fertigmontiertam;
	}

	public void setFertigmontiertam(String fertigmontiertam) {
		this.fertigmontiertam = fertigmontiertam;
	}
	
	public String getFertigmontiertvon() {
		return fertigmontiertvon;
	}
	
	public void setFertigmontiertvon(String fertigmontiertvon) {
		this.fertigmontiertvon = fertigmontiertvon;
	}
}
